package com.ruoyi.web.util;

import dev.langchain4j.model.chat.ChatModel;
import dev.langchain4j.model.openai.OpenAiChatModel;
import dev.langchain4j.service.AiServices;

public class ChatUtil {
    private static ChatModel model;

    /**
     * 使用静态初始化块，为私有的成员变量model初始化值
     */

    static {
        model = OpenAiChatModel.builder()
                .baseUrl("https://api.deepseek.com")
                .apiKey("sk-7204f840c0c44d0788c72f0ec53af764")
                .modelName("deepseek-chat")
                .build();
    }

    /**
     * 获取AIService的代理对象
     * @param clazz
     * @param <T>
     */

    public static<T> T getService(Class<T> clazz){
       return AiServices.create(clazz,model);
    }
}
